package com.dharma.mydiet.storage;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class TransactionalRegisterPersonal {
	private int idRegisterPersonal;
	private int idRegister;
	private int idUser;
	private Date date;
	private float quantity;

	public int getIdRegisterPersonal() {
		return idRegisterPersonal;
	}

	public void setIdRegisterPersonal(int idRegisterPersonal) {
		this.idRegisterPersonal = idRegisterPersonal;
	}

	public int getIdRegister() {
		return idRegister;
	}

	public void setIdRegister(int idRegister) {
		this.idRegister = idRegister;
	}

	public int getIdUser() {
		return idUser;
	}

	public void setIdUser(int idUser) {
		this.idUser = idUser;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public float getQuantity() {
		return quantity;
	}

	public void setQuantity(float quantity) {
		this.quantity = quantity;
	}

	public TransactionalRegisterPersonal(int idRegisterPersonal, int idRegister, int idUser, String date, float quantity) {
		super();
		this.idRegisterPersonal = idRegisterPersonal;
		this.idRegister = idRegister;
		this.idUser = idUser;
		this.setDateFormattedString(date);
		this.quantity = quantity;
	}

	@Override
	public String toString() {
		return "TransactionalRegisterPersonal [idRegisterPersonal=" + idRegisterPersonal + ", idRegister=" + idRegister
				+ ", idUser=" + idUser + ", date=" + date + ", quantity=" + quantity + "]";
	}

	public void setDateFormattedString(String formattedDateString) {
		SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", new Locale("us"));
		try {
			date = sdf.parse(formattedDateString);
		} catch (ParseException e) {
			System.out.println("Error");
			e.printStackTrace();
		}
	}

	public String getDateFormattedString() {
		return "" + date.toString();
	}

}
